<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
//预编译     
			
			/*
			test();
			function test(){
				console.log('a');
			}
			test();
			*/
			
			/*
			console.log(a);//undefined
			var a = 123
			*/
			
			//函数声明整体提升，变量声明提升
			/*var a = 123;//变量声明➕提升*/
			
			/**
			console.log(a);//function a(a){}
			function a(a){
				var a = 234;
				var a = function(){
					
				}
				a();
			}
			var a = 123;
			*/
			
//imply global 暗示全局变量：即任何变量，如果变量未经声明就复制，此变量就为全局对象所有
			
			
			/*function test(){
				a = 123;
			}
			console.log(a);
			test();*/
//一切声明的全局变量，全是window的属性
			
			/*var a = 123;
			console.log(window.a);//window是全局的域*/
			
			/*function test(){
				var a = b = 234;
			}
			
			test();
			console.log(a);//a is not defined
			console.log(b);//234
			*/
//预编译 发生在函数执行前一刻
			/**
			 * 1.生成AO对象 Activation Object(执行器上下文)
			 * 2.找形参和变量声明
			 * 3.将实参和形参相统一
			 * 4 函数声明
			 * 
			 * ==================1==================
			 * AO{}
			 * ==================2==================
			 * AO{
			 * 		a : undefined
			 * 		b : undefined
			 * }
			 * ==================3==================
			 * AO{
			 * 		a : 1
			 * 		b : undefined
			 * }
			 * ==================4==================
			 * AO{
			 * 		a: function a(){}
			 * 		b: undefined
			 * 		d: function d(){}
			 * }
			 * 执行函数
			 * 
			 * var a = 123;
			 * AO{
			 * 		a: 123
			 * 		b: function(){}
			 * 		d: function d(){}
			 * }			 * 
			 */
/*			function fn(a){
				console.log(a);//function a(){}
				console.log(b);
				var a = 123; 
				console.log(a);//123
				function a(){}
				console.log(a);//123
				var b = function(){}
				console.log(b);//function(){}
				function d(){}
			}
			fn(1);*/
			
/*			function test(a,b){
				console.log(a);//1
				c = 0;
				var c;
				a = 3;
				b = 2;
				console.log(b);//2
				function b(){}
				function d(){}
				console.log(b);//2
			}
			test(1);*/
			
/*			function test(){
				console.log(a);//function a(){}
				console.log(b);//undefined
				var b = 234;
				console.log(b);//234
				a = 123;
				console.log(a);//123
				function a(){}
				var a;
				b = 234;
				var b = function(){}
				console.log(a);//123
				console.log(b);//function(){}
			}
			test(1);*/
			
			
			/*	生成一个GO对象 Global Object
				GO ==Window*/
			
			/*console.log(a);
			var a = 123;//undefined*/
			
			/*console.log(b);//function b(){}	
			var b = 234;
			function b(){}	*/
			
			/*console.log(test);//function test(){}
			function test(test){
				console.log(test);//function test(){}
				var test = 234;
				console.log(test);//234
				function test(){}
				console.log(test);//234
			}
			test(1);
			var test = 123;*/
			
			/*var global = 100;
			 function fn(){
			 	console.log(global);//100
			 }
			 fn();*/
			
			/*console.log(global);//undefined
			global = 100;
			console.log(global);//100
			function fn(){
				console.log(global);//undefined
				global = 200;
				console.log(global);//200
				var global = 300;
				console.log(global);//300
			}
			fn();
			var global;*/
			
			/*function test(){
			 	console.log(a);//u
				console.log(b);//u
				if(a){
					var b = 100;
				}
				console.log(b);//u
				c = 234;
				console.log(c);//234
			}
			var a;
			test();
			a = 10;
			console.log(c);//234*/
			
			/*function bar(){
				return foo;
				foo = 10;
				function foo(){}
				var foo = 11;
			}
			console.log(foo);//foo is not undefined*/
			
			/*console.log(bar());//11
			function bar(){
				foo = 10;
				function foo(){}
				var foo = 11;
				return foo;
			}*/
			
			
			
			
		</script>
	</body>
</html>
